package com.shadow.ui.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

/**
 * @author zhangyu
 * @date 2018/1/5
 */

public class SingleChoiceDialogUtil {

    public static void showDialog(Context context,
                                  CharSequence[] items,
                                  CharSequence checkedStr,
                                  final DialogInterface.OnClickListener listener) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(context);
        int index = 0;
        for (CharSequence str : items) {
            if (str.equals(checkedStr)) {
                break;
            }
            index++;
        }
        builder.setSingleChoiceItems(items, index, listener);
        builder.show();
    }
}
